# encoding:utf-8

"""
1、部分代码出现次数较高，可以优化为一行
    例如：assert r.json()["status"] == login_data["exp"]["status"]
    assert r.json()["code"] == login_data["exp"]["code"]
    assert r.json()["msg"] == login_data["exp"]["msg"]
2、避免pytest_check代替assert避免断言失败后，断言后面的语句执行不到

"""
import pytest_check

def equal(real,exp,keys=["status","code","msg"]):
    #     遍历每一个要比较的键
    for k in keys:
        r = str(real[k])
        e = str(exp[k])
        if pytest_check.equal(r,e):
            print("校验",k,"成功，实际结果为：",r,"预期结果为",e)
        else:
            print("校验",k,"失败，实际结果为：",r,"预期结果为",e)